Skip to content

Add support for SLH-DSA - #512

Open
padelsbach wants to merge 1 commit into
wolfSSL:mainfrom
padelsbach:add-crypto-cb-slhdsa
Open

padelsbach wants to merge 1 commit into
wolfSSL:mainfrom
padelsbach:add-crypto-cb-slhdsa

Conversation

@padelsbach

Copy link
Copy Markdown
Contributor

No description provided.

@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch 2 times, most recently from aed3238 to 7fe4069 Compare August 21, 2026 23:20
@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch 4 times, most recently from 64514ae to a9eb8a9 Compare September 16, 2026 19:16
@padelsbach
padelsbach marked this pull request as ready for review September 16, 2026 19:49
@padelsbach
padelsbach requested review from Frauschi, bigbrett and wolfSSL-Fenrir-bot and removed request for bigbrett September 16, 2026 19:49

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #512

Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

Findings: 11
11 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/wh_client_cryptocb.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_server_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #512

Scan targets checked: wolfhsm-core-bugs, wolfhsm-crypto-bugs, wolfhsm-src

Findings: 7
7 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_server_crypto.c Resolved
Comment thread src/wh_server_crypto.c Resolved
Comment thread src/wh_server_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_server_crypto.c Resolved

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the SLH-DSA callback support. Big addition, and the structure mirrors the ML-DSA paths closely enough to follow easily.

Comments inline. The ones I would most like to see addressed are the DMA READ_POST after a denied READ_PRE in _HandleSlhDsaVerifyDma, the unvalidated seedSz / 3 in both keygen handlers, and the seed left resident in the comm packet. The rest are smaller consistency points against the ML-DSA and ML-KEM siblings, and the last few are nits you can take or leave.

Nothing here is a blocker.

Comment thread src/wh_client_cryptocb.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_server_crypto.c Resolved
Comment thread src/wh_crypto.c Resolved
Comment thread wolfhsm/wh_message_crypto.h Resolved
Comment thread src/wh_server_crypto.c Resolved
Comment thread test-refactor/wh_test_list.c Resolved

@Frauschi Frauschi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small follow-ups from the last round - neither is blocking, and the rest of what I raised looks good now.

Comment thread src/wh_server_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
@Frauschi Frauschi removed their assignment Sep 22, 2026
Frauschi
Frauschi previously approved these changes Sep 23, 2026
@Frauschi Frauschi assigned bigbrett and unassigned Frauschi Sep 23, 2026
@padelsbach padelsbach changed the title Add crypto callback mode for SLH-DSA Add support for for SLH-DSA Sep 25, 2026
Copilot AI balanced review requested due to automatic review settings October 2, 2026 20:18
@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch from aedd93b to 69839ec Compare October 2, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Cache-mode flag handling, DER error reporting, and DMA cleanup can currently produce false success or leave unintended cached keys.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds end-to-end SLH-DSA support across wolfHSM, including key management, signing, verification, DMA, crypto callbacks, examples, and CI coverage.

Changes:

  • Adds SLH-DSA wire protocols and client/server cryptographic operations.
  • Supports cached, exported, seeded, non-DMA, DMA, and callback-only workflows.
  • Extends configuration, tests, examples, and CI for SLH-DSA.
File Description
wolfhsm/​wh_settings.h Documents SLH-DSA buffer requirements.
wolfhsm/​wh_server_crypto.h Declares server cache helpers.
wolfhsm/​wh_message_crypto.h Defines SLH-DSA wire messages.
wolfhsm/​wh_crypto.h Declares DER serialization support.
wolfhsm/​wh_common.h Adds the SLH-DSA algorithm identifier.
wolfhsm/​wh_client_crypto.h Exposes client SLH-DSA APIs.
test/​wh_test_check_struct_padding.c Covers new message layouts.
test/​config/​user_settings.h Enables SLH-DSA in tests.
test-refactor/​wh_test_list.c Registers SLH-DSA tests.
test-refactor/​posix/​Makefile Adds verify-only configuration.
test-refactor/​misc/​wh_test_check_struct_padding.c Covers refactored message layouts.
src/​wh_server_keystore.c Supports public-key export.
src/​wh_server_crypto.c Implements server operations and DMA handlers.
src/​wh_message_crypto.c Implements message translation.
src/​wh_crypto.c Implements SLH-DSA DER conversion.
src/​wh_client_cryptocb.c Integrates wolfCrypt callbacks.
src/​wh_client_crypto.c Implements client and DMA APIs.
examples/​posix/​wh_posix_server/​user_settings.h Enables server-side SLH-DSA.
examples/​posix/​wh_posix_client/​user_settings.h Enables client and callback-only modes.
examples/​posix/​wh_posix_client/​Makefile Adds callback-only build selection.
examples/​demo/​client/​wh_demo_client_crypto.h Declares the SLH-DSA demo.
examples/​demo/​client/​wh_demo_client_crypto.c Implements the SLH-DSA demo.
examples/​demo/​client/​wh_demo_client_all.c Runs the SLH-DSA demo.
.github/​workflows/​build-and-test-refactor.yml Tests verify-only builds.
.github/​workflows/​build-and-run-examples.yml Tests callback-only operation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_client_crypto.c Resolved
Comment thread src/wh_crypto.c Resolved
@padelsbach
padelsbach requested review from Frauschi and a balanced review from Copilot October 3, 2026 00:42
@padelsbach padelsbach removed their assignment Oct 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Non-DMA responses expose uninitialized padding, and the server header lacks the required SLH-DSA type include.

Review effort: Balanced
Findings: 2 High severity

Open (2)
Resolved since last review (3)

Comment thread src/wh_server_crypto.c Resolved
Comment thread wolfhsm/wh_server_crypto.h Resolved
@bigbrett bigbrett assigned padelsbach and unassigned bigbrett Oct 5, 2026
@bigbrett

bigbrett commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@padelsbach can you check the copilot comments and address if necessary, otherwise resolve and reassign me plz

@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch 2 times, most recently from bbc5a63 to aa14855 Compare October 9, 2026 16:06
@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch from fe43259 to 9efa82f Compare October 13, 2026 04:40
@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch from d408125 to 7531b59 Compare October 30, 2026 01:04

@bigbrett bigbrett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nits and a concern about the silent fallback. Also need to update PQC algo list in docs to include SLH-DSA. Also needs rebase and conflicts resolved. Perhaps squash the commits as well since you are rebasing anyway.

if: matrix.group == 'pq-dma'
run: cd test-refactor/posix && make clean && make -j DMA=1 ASAN=1 MLDSA_VERIFY_ONLY=1 WOLFSSL_DIR=../../wolfssl && make run

# Verify-only drops the signing APIs, so this catches code that assumes them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Verify-only drops the signing APIs, so this catches code that assumes them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

word32 sigLen = sizeof(signature);
byte addRnd[WC_SLHDSA_MAX_SEED];

memset(addRnd, 0x42, sizeof(addRnd));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer to the ultimate question. But perhaps also a comment saying "placeholder for user-supplied random input"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment

Comment thread examples/posix/wh_posix_client/Makefile Outdated
endif

ifeq ($(SLHDSA_CB_ONLY),1)
DEF += -DWH_CFG_SLHDSA_CB_ONLY

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did WH_CFG_xxx come from? Our wolfHSM config macros are spelled WOLFHSM_CFG_XXXX

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, good catch. Fixed

Comment thread src/wh_client_crypto.c
Comment on lines +11540 to +11544
do {
ret = wh_Client_RecvResponse(ctx, &group, &action, &res_len,
WOLFHSM_CFG_COMM_DATA_LEN,
(uint8_t*)dataPtr);
} while (ret == WH_ERROR_NOTREADY);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for a first stab, but we will eventually need async split transaction Request/response functions for all of these in the client API. Then the blocking one can just send the request and block on the response. wolfCrypt cryptocallback will then just use the blocking API. See how all the other crypto algorithms are implemetned in client API.

Def need a follow up PR with this. Fine for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async split is a big change. Punting on that for now

Comment thread src/wh_client_cryptocb.c Outdated
if ((ret == WH_ERROR_REQUEST_SIZE) && _PqcSigCanVerifyLocally(type, key)) {
ret = CRYPTOCB_UNAVAILABLE;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this. Seems yet another place where we can silently fall back to local crypto on the client side. IMO this is a bad pattern. We dont want any surprises. IMO if the user explicitly requests something to go the HSM it should fail when it doesn't. There are already some edge cases in teh current code and I don't want to add more. Any reason you did it this way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this on the other PR too, trying to get too fancy. Removed.

Comment thread src/wh_client_cryptocb.c Resolved
@bigbrett bigbrett assigned padelsbach and unassigned bigbrett and padelsbach Oct 30, 2026
@padelsbach padelsbach changed the title Add support for for SLH-DSA Add support for SLH-DSA Nov 13, 2026
@padelsbach
padelsbach force-pushed the add-crypto-cb-slhdsa branch 2 times, most recently from c863daf to 352ff0e Compare November 13, 2026 23:38
@padelsbach padelsbach assigned bigbrett and unassigned padelsbach Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants